home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / mimelib / msgid.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-05-14  |  6.9 KB  |  181 lines

  1. //=============================================================================
  2. // File:       msgid.h
  3. // Contents:   Declarations for DwMsgId
  4. // Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
  5. // WWW:        http://www.fwb.gulf.net/~dwsauder/mimepp.html
  6. //
  7. // Copyright (c) 1996, 1997 Douglas W. Sauder
  8. // All rights reserved.
  9. //
  10. // IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
  11. // INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
  12. // THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
  13. // HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. //
  15. // DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
  16. // NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  17. // PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
  18. // BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
  19. // SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  20. //
  21. //=============================================================================
  22.  
  23. #ifndef DW_MSGID_H
  24. #define DW_MSGID_H
  25.  
  26. #ifndef DW_CONFIG_H
  27. #include <mimelib/config.h>
  28. #endif
  29.  
  30. #ifndef DW_FIELDBDY_H
  31. #include <mimelib/fieldbdy.h>
  32. #endif
  33.  
  34. //=============================================================================
  35. //+ Name DwMsgId -- Class representing an RFC-822 msg-id
  36. //+ Description
  37. //. {\tt DwMsgId} represents a {\it msg-id} as described in RFC-822.  In
  38. //. the BNF grammar in RFC-822, a msg-id has a {\it local-part} and a
  39. //. {\it domain}.  In MIME++, a {\tt DwMsgId} contains strings that
  40. //. contain the local-part and the domain.
  41. //.
  42. //. In the tree (broken-down) representation of message, a {\tt DwMsgId}
  43. //. object may only be a leaf node, having a parent but no child nodes.
  44. //. Its parent node must be a {\tt DwField} object.
  45. //.
  46. //. {\tt DwMsgId} has member functions for getting or setting its local-part
  47. //. and its domain.  You can have the library to create the contents of a
  48. //. {\tt DwMsgId} object for you by calling the member function
  49. //. {\tt CreateDefault()}.
  50. //=============================================================================
  51. // Last modified 1997-07-28
  52. //+ Noentry ~DwMsgId mLocalPart mDomain sClassName _PrintDebugInfo
  53.  
  54.  
  55. class DW_EXPORT DwMsgId : public DwFieldBody {
  56.  
  57. public:
  58.  
  59.     DwMsgId();
  60.     DwMsgId(const DwMsgId& aMsgId);
  61.     DwMsgId(const DwString& aStr, DwMessageComponent* aParent=0);
  62.     //. The first constructor is the default constructor, which sets the
  63.     //. {\tt DwMsgId} object's string representation to the empty string
  64.     //. and sets its parent to NULL.
  65.     //.
  66.     //. The second constructor is the copy constructor, which performs
  67.     //. a deep copy of {\tt aMsgId}.
  68.     //. The parent of the new {\tt DwMsgId} object is set to NULL.
  69.     //.
  70.     //. The third constructor copies {\tt aStr} to the {\tt DwMsgId}
  71.     //. object's string representation and sets {\tt aParent} as its parent.
  72.     //. The virtual member function {\tt Parse()} should be called immediately
  73.     //. after this constructor in order to parse the string representation.
  74.     //. Unless it is NULL, {\tt aParent} should point to an object of a class
  75.     //. derived from {\tt DwField}.
  76.  
  77.     virtual ~DwMsgId();
  78.  
  79.     const DwMsgId& operator = (const DwMsgId& aMsgId);
  80.     //. This is the assignment operator, which performs a deep copy of
  81.     //. {\tt aMsgId}.  The parent node of the {\tt DwMsgId} object
  82.     //. is not changed.
  83.  
  84.     virtual void Parse();
  85.     //. This virtual function, inherited from {\tt DwMessageComponent},
  86.     //. executes the parse method for {\tt DwMsgId} objects.  The parse
  87.     //. method parses the local-part and the domain from the string
  88.     //. representation.
  89.     //.
  90.     //. You should call this member function after you set or modify the
  91.     //. string representation, and before you retrieve local-part or
  92.     //. domain.
  93.     //.
  94.     //. This function clears the is-modified flag.
  95.  
  96.     virtual void Assemble();
  97.     //. This virtual function, inherited from {\tt DwMessageComponent},
  98.     //. executes the assemble method for {\tt DwMsgId} objects.  The
  99.     //. assemble method creates or updates the string representation
  100.     //. from the local-part and the domain.
  101.     //.
  102.     //. You should call this member function after you modify the
  103.     //. local-part or the domain, and before you retrieve the string
  104.     //. representation.
  105.     //.
  106.     //. This function clears the is-modified flag.
  107.  
  108.     virtual DwMessageComponent* Clone() const;
  109.     //. This virtual function, inherited from {\tt DwMessageComponent},
  110.     //. creates a new {\tt DwMsgId} on the free store that has the same
  111.     //. value as this {\tt DwMsgId} object.  The basic idea is that of
  112.     //. a ``virtual copy constructor.''
  113.  
  114.     virtual void CreateDefault();
  115.     //. Creates a value for the msg-id.  Uses the current time,
  116.     //. process id, and fully qualified domain name for the host.
  117.  
  118.     const DwString& LocalPart() const;
  119.     //. Returns the local-part of the msg-id.
  120.  
  121.     void SetLocalPart(const DwString& aLocalPart);
  122.     //. Sets the local-part of the msg-id.
  123.  
  124.     const DwString& Domain() const;
  125.     //. Returns the domain of the msg-id.
  126.  
  127.     void SetDomain(const DwString& aDomain);
  128.     //. Sets the domain of the msg-id.
  129.  
  130.     static DwMsgId* NewMsgId(const DwString& aStr,
  131.         DwMessageComponent* aParent);
  132.     //. Creates a new {\tt DwMsgId} object on the free store.
  133.     //. If the static data member {\tt sNewMsgId} is NULL,
  134.     //. this member function will create a new {\tt DwMsgId}
  135.     //. and return it.  Otherwise, {\tt NewMsgId()} will call
  136.     //. the user-supplied function pointed to by {\tt sNewMsgId},
  137.     //. which is assumed to return an object from a class derived from
  138.     //. {\tt DwMsgId}, and return that object.
  139.  
  140.     //+ Var sNewMsgId
  141.     static DwMsgId* (*sNewMsgId)(const DwString&, DwMessageComponent*);
  142.     //. If {\tt sNewMsgId} is not NULL, it is assumed to point to a
  143.     //. user-supplied function that returns an object from a class derived from
  144.     //. {\tt DwMsgId}.
  145.  
  146.     static const char* sHostName;
  147.     //. Host name of machine, used to create msg-id string.  This data member
  148.     //. is ignored if the platform supports a gethostname() function call.
  149.  
  150. private:
  151.  
  152.     DwString mLocalPart;
  153.     DwString mDomain;
  154.     static const char* const sClassName;
  155.  
  156. public:
  157.  
  158.     virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
  159.     //. This virtual function, inherited from {\tt DwMessageComponent},
  160.     //. prints debugging information about this object to {\tt aStrm}.
  161.     //. It will also call {\tt PrintDebugInfo()} for any of its child
  162.     //. components down to a level of {\tt aDepth}.
  163.     //.
  164.     //. This member function is available only in the debug version of
  165.     //. the library.
  166.  
  167.     virtual void CheckInvariants() const;
  168.     //. Aborts if one of the invariants of the object fails.  Use this
  169.     //. member function to track down bugs.
  170.     //.
  171.     //. This member function is available only in the debug version of
  172.     //. the library.
  173.  
  174. protected:
  175.  
  176.     void _PrintDebugInfo(std::ostream& aStrm) const;
  177.  
  178. };
  179.  
  180. #endif
  181.